<template>
	<view>
		<!--banner-->
		<swiper indicator-dots autoplay circular :interval="5000" :duration="150" indicator-color="rgba(255, 255, 255, 0.9)"
		 indicator-active-color="#5677fc" class="tui-banner-swiper" :style="{height: bannerHeight+'rpx'}">
			<swiper-item v-for="(item,index) in couponList" :key="index">
				<!-- <view class="tui-banner-title">{{item.title}}</view> -->
				<image :src="item.picUrl" class="tui-slide-image" mode="widthFix" />
			</swiper-item>
		</swiper>
		<view class="container">

			<view class="tui-coupon-item tui-top20" v-for="(item,index) in couponList" :key="index">
				<image src="../../../static/images/coupon/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
				<view class="tui-coupon-price-box">
					<view class="tui-coupon-item-left">
						<image src="../../../static/images/shop/ele.png" class="ele-img" v-if="item.platform==2"></image>
						<image src="../../../static/images/shop/meituan.png" class="mt-img" v-else></image>
					</view>
					<view class="tui-coupon-item-right">
						<view class="tui-coupon-price-sign">{{item.platformName}}</view>
						<view class="tui-coupon-price">{{item.couponName}}</view>
					</view>
				</view>
				<view class="tui-btn-box" @click="toMini(item.linkUrl,item.platform)">
					<tui-button type="danger" width="152rpx" height="52rpx" :size="24" shape="circle" plain>立即领取</tui-button>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		BASE_URL
	} from "../../../common/httpRequest.js"
	export default {

		data() {
			return {
				baseUrl: BASE_URL,
				couponList: [],
				bannerHeight:200,

			};
		},
		onLoad() {
			let _this=this
			uni.getSystemInfo({
				success: function(res) {
					_this.bannerHeight=res.windowWidth/1098*400*2	
				}
			})
			this.getList()
		},
		methods: {
			getList() {
				this.tui.request(
						"/api/coupon/list",
						"GET", {},
						false,
						false,
						false
					)
					.then((res) => {
						this.couponList = res.data

					});
			},
			toMini(path, platform) {
				uni.navigateToMiniProgram({
					appId: platform == 2 ? 'wxece3a9a4c82f58c9' : 'wxde8ac0a21135c07d',
					path: path

				})
			}
		}
	};
</script>

<style>
	page {
		background-color: #F5F5F5;
	}

	.container {
		width: 100%;
		padding: 30rpx;
	}

	.tui-banner-swiper {
		width: 100%;
		
		position: relative;
	}

	.tui-slide-image {
		width: 100%;
		display: block;
	}

	.tui-coupon-list {
		width: 100%;
		padding: 0 25rpx;
		box-sizing: border-box;
	}



	.tui-coupon-item {
		width: 100%;
		height: 180rpx;
		position: relative;
		display: flex;
		align-items: center;
		padding-right: 30rpx;
		box-sizing: border-box;
		overflow: hidden;
	}

	.tui-coupon-bg {
		width: 100%;
		height: 210rpx;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
	}

	.tui-coupon-sign {
		height: 90rpx;
		width: 110rpx;
		position: absolute;
		z-index: 9;
		top: -30rpx;
		right: 40rpx;
	}

	.ele-img {
		width: 80rpx;
		height: 80rpx;
	}

	.mt-img {
		width: 100rpx;
		height: 80rpx;
	}

	.tui-coupon-item-left {
		width: 140rpx;
		height: 180rpx;
		position: relative;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		flex-shrink: 0;
	}

	.tui-coupon-price-box {
		display: flex;
	}

	.tui-coupon-price-sign {
		font-size: 24rpx;
	}

	.tui-coupon-price {
		font-size: 30rpx;
		color: #e41f19;
		margin-top: 24rpx;
	}

	.tui-coupon-item-right {
		display: flex;
		flex-direction: column;
		height: 180rpx;
		padding-top: 40rpx;
		box-sizing: border-box;
		z-index: 2;
	}


	.tui-top20 {
		margin-top: 20rpx;
	}

	.tui-coupon-title {
		font-size: 28rpx;
		line-height: 28rpx;
	}

	.tui-btn-box {
		position: absolute;
		width: 160rpx;
		height: 180rpx;
		right: 0;
		bottom: 0;
		z-index: 10;
		display: flex;
		align-items: center;
	}
</style>
